//
//  myFootmarkViewController.m
//  LT
//
//  Created by dllo on 16/5/25.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "myFootmarkViewController.h"
#import "myFootCollectionViewCell.h"

@interface myFootmarkViewController ()<UICollectionViewDataSource,UICollectionViewDelegate>


//装足迹的数组
@property(nonatomic,strong)NSMutableArray *myArray;

@end

@implementation myFootmarkViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor redColor];
    
    self.myArray = [NSMutableArray array];
    
    
    self.myArray = [NSMutableArray arrayWithObjects:[UIImage imageNamed:@"order"],[UIImage imageNamed:@"myDis"],[UIImage imageNamed:@"like"],[UIImage imageNamed:@"wanttogo"],[UIImage imageNamed:@"zuji"],[UIImage imageNamed:@"like"],[UIImage imageNamed:@"like"], [UIImage imageNamed:@"like"],[UIImage imageNamed:@"friend"],nil];
    
    
    
    //flowLayout布局
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    //设置每个item的大小(这里的item相当于我们tableView中的cell)
    flowLayout.itemSize = CGSizeMake(120, 190);
    //flowLayout距离屏幕上下左右的距离
    flowLayout.sectionInset = UIEdgeInsetsMake(30, 10, 30, 10);
    //设置滑动方向(竖滑)
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    //collection
    UICollectionView *myFootCollectionV = [[UICollectionView alloc]initWithFrame:self.view.frame collectionViewLayout:flowLayout];
    
    //myFootCollectionV.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:myFootCollectionV];
    
    myFootCollectionV.delegate = self;
    myFootCollectionV.dataSource = self;
    
    //注册
    [myFootCollectionV registerClass:[myFootCollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
    
    
   //跳转回原来界面的button
  self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"goback"] style:UIBarButtonItemStylePlain target:self action:@selector(leftButtonAction)];
    
}

//跳转回去我的界面
-(void)leftButtonAction{

[self dismissViewControllerAnimated:YES completion:^{
    
    
}];


}


//collection对应俩个方法
//item的个数
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.myArray.count;

}

//item将要显示的时候执行(也就是创建item的主要方法)
-(myFootCollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    myFootCollectionViewCell *item = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    
    item.imageV.image = [self.myArray objectAtIndex:indexPath.row];


    
    return item;
}

//cell的点击方法
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
//逻辑:如果有用户登录就显示收藏,如果没有就显示空





}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
